var formatNumber = function(num) {
  let numstr = String(num).split('.');
  let pre = numstr[0];
  let surfix = numstr[1] ? `.${numstr[1]}` : '';
  let str = String(num);
  str = pre.replace(/(\d{1,3})(?=(\d{3})+$)/g, '$1,')
  console.log(str)
}

formatNumber(1234567891210.11111)